<!DOCTYPE html>
<html>
  <head>
    <title>Listing 7.6</title>
    <script type="text/javascript" src="../scripts/assert.js"></script>
    <link href="../styles/assert.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <script type="text/javascript">

      var html = "<div class='test'><b>Hello</b> <i>world!</i></div>";
      var pattern = /<(\/?)(\w+)([^>]*?)>/g, match;
      var num = 0;

      while ((match = pattern.exec(html)) !== null) {                  //#1
        assert(match.length == 4,
              "Every match finds each tag and 3 captures.");
        num++;
      }

      assert(num == 6, "3 opening and 3 closing tags found.");

    </script>
  </body>
</html>
